<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            /* 
            
            */
            var restoreIpAddresses = function (s) {
                let res = []
                function backTacking(path, start) {
                    if (path.length > 4) return
                    if (path.length == 4 && start == s.length) {
                        return res.push([...path])
                    }
                    for (let i = start; i < start + 3; i++) {
                        let str = s.slice(start, i + 1)
                        if (Number(str) < 0 || Number(str) > 255) continue
                        if (str.length > 1 && str[0] == "0") continue
                        path.push(str)
                        backTacking(path, i + 1)
                        path.pop()
                    }
                }
                backTacking([], 0)
                return res
            }
        </script>
    </body>
</html>
